/// Creator:      gaoruishan
/// CreatDate:    2025-06-14
/// Description:  检查
Class Nur.MNISV3.Service.Ris Extends %RegisteredObject [ Not ProcedureBlock ]
{

/// 检查列表
/// w ##class(Nur.MNISV3.Service.Ris).GetExamOrderDataV4("","2023-07-11","2024-06-13","3","20665","8","{""single"":"""",""multiple"":""1""}")
ClassMethod GetExamOrderDataV4(episodeId, fromDate, toDate, wardId, userId, locId, extras)
{
    n (episodeId,fromDate,toDate, wardId, userId, locId, extras)
    s $zt="errGetExamOrderDataV4"
    s ^GRS("GetExamOrderDataV4")=$lb(episodeId,fromDate,toDate, wardId, userId, locId, extras)
    s Msg="成功",msgcode="999999",Status="0" //定义初始值
    s json=##class(%ArrayOfDataTypes).%New()
    s fromDate=##class(websys.Conversions).DateHtmlToLogical(fromDate)
    s toDate=##class(websys.Conversions).DateHtmlToLogical(toDate)
    s patInfoList=##class(%ListOfDataTypes).%New()
    i episodeId'="" { //单患者
       s patinfo=##class(%ArrayOfDataTypes).%New()
       s patinfo=##class(Nur.MNISV3.Service.Patient).GetBasicInfo(patinfo,episodeId)
       d patInfoList.Insert(patinfo)
    }else {
        //调用纯净版患者列表，
        s patListObj=##class(%ResultSet).%New("Nur.MNISV3.Service.Patient:GetPatList")
        d patListObj.Execute(wardId,userId,"Ward",locId)
        
        while(patListObj.Next()){
           s patinfo= ##class(Nur.MNISV3.Common.Utils).ResultSet(patListObj)
           s episodeId=patListObj.GetDataByName("episodeId")
           //基本患者信息
           s patinfo=##class(Nur.MNISV3.Service.Patient).GetBasicInfo(patinfo,episodeId)
           //检查信息
           s examOrderData=##class(Nur.MNISV3.Service.Ris).SelectLISItemListByDate(episodeId,fromDate,toDate)
           d patinfo.SetAt(examOrderData,"examOrderData")
           d patInfoList.Insert(patinfo)
        }
    }
    
    d json.SetAt($g(Msg),"msg")
    d json.SetAt($g(msgcode),"msgcode")
    d json.SetAt($g(Status),"status")
    d json.SetAt($g(patInfoList),"patients")
    q ##class(Nur.MNISV3.Common.JSON).Encode(json)
errGetExamOrderDataV4
    s Msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson(Msg,"100021","-1")
}

/// 获取详情
ClassMethod GetExamReportV4(oeoreId)
{
    n (oeoreId)  
    s $zt="errGetExamReportV4"
    s ^GRS("GetExamReportV4")=oeoreId
    s Msg="成功",msgcode="999999",Status="0" //定义初始值
    s json=##class(%ArrayOfDataTypes).%New()
    s Report=##class(%ListOfDataTypes).%New() 
    s LisOrdres=##class(%ResultSet).%New("web.DHCENS.STBLL.Method.PostReportInfo:SelectReportByOeordID")
    d LisOrdres.Execute(oeoreId)
    while LisOrdres.Next()
    {
        s LabOrdData= ##class(Nur.MNISV3.Common.Utils).ResultSet(LisOrdres)
        d Report.Insert(LabOrdData)
    }
    d json.SetAt($g(Msg),"msg")
    d json.SetAt($g(msgcode),"msgcode")
    d json.SetAt($g(Status),"status")
    d json.SetAt($g(Report),"Report")
    q ##class(Nur.MNISV3.Common.JSON).Encode(json)
errGetExamReportV4
    s Msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson(Msg,"100021","-1")
}

ClassMethod SelectLISItemListByDate(EpisodeID, Begdate, EndDate, FExistReport = "")
{
    
    n (EpisodeID , Begdate , EndDate, FExistReport)
    s risOrdList=##class(%ListOfDataTypes).%New() 
    s LisOrdres=##class(%ResultSet).%New("web.DHCENS.STBLL.Method.PostReportInfo:SelectPACSItemListByDate")
    d LisOrdres.Execute(EpisodeID,Begdate,EndDate)
    while LisOrdres.Next()
    {
        s LabOrdData= ##class(Nur.MNISV3.Common.Utils).ResultSet(LisOrdres)
        d risOrdList.Insert(LabOrdData)
    }
    q risOrdList
}

}
